package cn.zwx.security.example.security.handler;

import cn.zwx.security.example.common.enums.ResultCodeEnum;
import cn.zwx.security.example.utils.ResultUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description 用户未登录处理类
 * @return
 * @author zhangwenxue
 * @createTime 2021/6/23 16:04
 **/
@Component
public class UserAuthenticationEntryPointHandler implements AuthenticationEntryPoint {
   /**
    * @description  用户未登录处理类
    * @return void
    * @author zhangwenxue
    * @createTime 2021/6/23 16:04
    **/
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception){
        ResultUtil.responseJson(response, ResultCodeEnum.NO_AUTH);
    }
}